package computer;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

/**
 * Created with IntelliJ IDEA.
 * Description:
 */
public class CardDemo {
    public static final String suits[] ={"梅花","方块","红桃","黑桃"};
    public List<Card> buyCard(){
        List<Card> cards =new ArrayList<>();
        for (int i = 1; i <= 13; i++) {
            for (int j = 0; j < 4; j++) {
                Card card =new Card(i,suits[j]);
                cards.add(card);
            }
        }
        return cards;
    }
    public void washCard(List<Card> cards ){
        Random random =new Random();
        for (int i = cards.size()-1; i >0 ; i--) {
            int index =random.nextInt(i);
            Card tmp = cards.get(index);
            cards.set(index,cards.get(i));
            cards.set(i,tmp);
        }
    }
    public void play(List<Card> cards){
        List<Card> person1 =new ArrayList<>();
        List<Card> person2 =new ArrayList<>();
        List<Card> person3 =new ArrayList<>();
        List<List<Card>> sum =new ArrayList<>();
        sum.add(person1);
        sum.add(person2);
        sum.add(person3);
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j < 3; j++) {
                sum.get(j).add(cards.remove(0));
            }
        }
        for (int i = 0; i < sum.size(); i++) {
            for (int j = 0; j < sum.get(i).size(); j++) {
                System.out.print(sum.get(i).get(j)+" ");
            }
            System.out.println();
        }
    }
}

